import java.util.List;
import java.util.Map;

public class CourseRegistrationTest {
    public static void main(String[] args) {
        Database db = new Database();
        // 添加课程
        db.addCourse(new Course("数学", "张老师", "周一 3 - 4 节", "A101"));
        db.addCourse(new Course("英语", "李老师", "周二 1 - 2 节", "B202"));
        // 添加学生
        db.addStudent(new Student("S001", "张三", "123456789"));
        db.addStudent(new Student("S002", "李四", "987654321"));
        // 添加教师
        Teacher teacher = new Teacher("T001", "王老师");

        // 测试学生注册课程
        boolean result1 = db.studentRegister("S001", "数学");
        boolean result2 = db.studentRegister("S002", "数学");
        assert result1;
        assert result2;

        // 测试注册不存在的课程
        boolean result = db.studentRegister("S001", "不存在的课程");
        assert!result;

        // 生成班级列表并测试
        Map<String, List<String>> classLists = db.generateClassLists();
        System.out.println("班级列表:");
        for (Map.Entry<String, List<String>> entry : classLists.entrySet()) {
            System.out.println(entry.getKey() + ":");
            for (String student : entry.getValue()) {
                System.out.println("  - " + student);
            }
        }
        assert classLists.get("数学")!= null && classLists.get("数学").size() == 2;
        assert classLists.get("数学").contains("张三");
        assert classLists.get("数学").contains("李四");
        assert classLists.get("英语") == null;

        // 教师查看班级列表
        teacher.viewClassLists(db);

        db.close();
    }
}
